package com.cy.pj.common.pojo.web;

import com.cy.pj.common.pojo.JsonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandle {

    private static final Logger log= LoggerFactory.getLogger(GlobalExceptionHandle.class);
    @ExceptionHandler(ArithmeticException.class)
    public JsonResult doHandleArithmeticException(ArithmeticException e){
    e.printStackTrace();
    log.info("exception {}",e.getMessage());
    return new JsonResult(e);//封装异常结果
    }
}
